package com.etoak.car.service;

import com.etoak.car.bean.Car;
import com.etoak.car.bean.Order;
import com.etoak.car.bean.Users;
import com.etoak.car.mapper.OrderMapper;
import com.etoak.commons.page.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderService {

    @Autowired
    OrderMapper orderMapper;


    public Page<Order> querySome(int pageNum, int pageSize) {
        //设置分页条件
        PageHelper.startPage(pageNum, pageSize);
        //查询功能
        List<Order> order = orderMapper.querySome();
        //创建pageInfo
        PageInfo<Order> pageInfo = new PageInfo<>(order);

        //返回结果
        return new Page<>(pageInfo.getPageNum(),
                pageInfo.getPageSize(),
                pageInfo.getTotal(),
                order,
                pageInfo.getPages());
    }

    public int delOrder(int id) {
        return orderMapper.delOrder(id);
    }

    public Page<Order> querySomeUser(int pageNum, int pageSize, int id) {
        //设置分页条件
        PageHelper.startPage(pageNum, pageSize);
        //查询功能
        List<Order> order = orderMapper.querySomeUser(id);
        //创建pageInfo
        PageInfo<Order> pageInfo = new PageInfo<>(order);

        //返回结果
        return new Page<>(pageInfo.getPageNum(),
                pageInfo.getPageSize(),
                pageInfo.getTotal(),
                order,
                pageInfo.getPages());

    }

    public int upHuanCarTime(String huandate, int id) {
        return orderMapper.upHuanCarTime(huandate, id);
    }

    public Order queryDate(int id) {
        return orderMapper.queryDate(id);
    }

    public int upCarStatus(int carid) {
        return orderMapper.upCarStatus(carid);
    }

    public Car getCarPrice(int carid) {
        return orderMapper.getCarPrice(carid);
    }

    public Users queryMoney(int userid) {
        return orderMapper.queryMoney(userid);
    }



    public int upOrderUserMoney(int userid, double money) {
        return orderMapper.upOrderUserMoney(userid, money);
    }




    public int setZuMoney(int userid, int carid, double orderPrice) {
        return orderMapper.setZuMoney(userid, carid, orderPrice);
    }

    public List<Order> queryByIds(String[] idss) {
        return orderMapper.queryByIds(idss);
    }
}
